/**
 * FloatDiv
 * @classDescription create a float Div scrolling with the browser window.
 * @dependence Mootools (http://www.mootools.net)
 * @author Aken.li (http://www.kxbd.com)
 * @version 1.0
 * @created   2009-01-25
 */
var FloatDiv = new Class({
	Implements:Options,

	options:{
		y:0,//到文档视图顶端的距离
		interval:0.01,//时长，单位为秒
		step:0.1//步长，数字越小，动画越慢，为1时无缓动动画
	},
	
	initialize:function(id,options){
		this.setOptions(options);
		this.obj = $(id);
		this.isActive = true;
		this.scrollFunc.periodical(this.options.interval*1000,this);
	},

	scrollFunc:function(){
		if(this.isActive){
			var posNow = parseInt(this.obj.getStyle('top'));
			var offset = (window.getScroll().y+this.options.y-posNow)*this.options.step;
			offset = offset > 0 ? Math.ceil(offset) : Math.floor(offset);
			this.obj.setStyle('top',posNow+offset);
		}
	},

	toggleActive:function(){
		this.isActive = this.isActive ? false:true;
	}
});